| 1 | #include "Project/LiveActor/SupportFreezeSyncGroup.h" |
|---|---|
| 2 | |
| 3 | #include "Library/HitSensor/HitSensorKeeper.h" |
| 4 | #include "Library/LiveActor/ActorSensorUtil.h" |
| 5 | #include "Library/LiveActor/LiveActor.h" |
| 6 | #include "Library/Placement/PlacementFunction.h" |
| 7 | |
| 8 | namespace al { |
| 9 | SupportFreezeSyncGroup::SupportFreezeSyncGroup() {} |
| 10 | |
| 11 | void SupportFreezeSyncGroup::init(const ActorInitInfo& info) { |
| 12 | alPlacementFunction::getLinkGroupId(groupId: mSupportFreezeSyncGroupId, initInfo: info, linkName: "SupportFreezeSyncGroup"); |
| 13 | |
| 14 | mActors = new LiveActor*[mMaxActorCount]; |
| 15 | for (s32 i = 0; i < mMaxActorCount; i++) |
| 16 | mActors[i] = nullptr; |
| 17 | } |
| 18 | |
| 19 | void SupportFreezeSyncGroup::regist(LiveActor* actor) { |
| 20 | if (mActorCount >= mMaxActorCount) |
| 21 | return; |
| 22 | |
| 23 | mActors[mActorCount] = actor; |
| 24 | mActorCount++; |
| 25 | } |
| 26 | |
| 27 | void SupportFreezeSyncGroup::setHostSensor(HitSensor* hostSensor) { |
| 28 | mHostSensor = hostSensor; |
| 29 | } |
| 30 | |
| 31 | bool SupportFreezeSyncGroup::isEqualGroupId(const ActorInitInfo& info) const { |
| 32 | if (!mSupportFreezeSyncGroupId->isValid()) |
| 33 | return false; |
| 34 | |
| 35 | PlacementId groupId; |
| 36 | if (!alPlacementFunction::getLinkGroupId(groupId: &groupId, initInfo: info, linkName: "SupportFreezeSyncGroup")) |
| 37 | return false; |
| 38 | |
| 39 | return mSupportFreezeSyncGroupId->isEqual(otherId: groupId); |
| 40 | } |
| 41 | |
| 42 | void SupportFreezeSyncGroup::movement() { |
| 43 | bool isAnyNerveSupportFreeze = false; |
| 44 | for (s32 i = 0; i < mActorCount; i++) |
| 45 | isAnyNerveSupportFreeze |= sendMsgIsNerveSupportFreeze( |
| 46 | receiver: mActors[i]->getHitSensorKeeper()->getSensor(index: 0), sender: mHostSensor); |
| 47 | |
| 48 | for (s32 i = 0; i < mActorCount; i++) |
| 49 | if (isAnyNerveSupportFreeze) |
| 50 | sendMsgOffSyncSupportFreeze(receiver: mActors[i]->getHitSensorKeeper()->getSensor(index: 0), |
| 51 | sender: mHostSensor); |
| 52 | else |
| 53 | sendMsgOnSyncSupportFreeze(receiver: mActors[i]->getHitSensorKeeper()->getSensor(index: 0), sender: mHostSensor); |
| 54 | } |
| 55 | } // namespace al |
| 56 |