protected override void SharedCreatePhysics(CreatePhysicsData data)
        {
            ProtoObjectWallHelper.SharedCalculateNeighborsPattern(
                data.GameObject.OccupiedTile,
                protoWall: this,
                out var sameTypeNeighbors,
                out _,
                isConsiderDestroyed: true,
                isConsiderConstructionSites: true);

            foreach (var pattern in WallPatterns.PatternsPrimary)
            {
                if (pattern.IsPass(sameTypeNeighbors))
                {
                    pattern.SetupPhysicsNormal?.Invoke(data.PhysicsBody);
                    return;
                }
            }
        }
Esempio n. 2
0
        protected override void SharedCreatePhysics(CreatePhysicsData data)
        {
            ProtoObjectWallHelper.SharedCalculateNeighborsPattern(
                data.GameObject.OccupiedTile,
                protoWall: data.PublicState.OriginalProtoObjectWall,
                out var sameTypeNeighbors,
                out _,
                isConsiderDestroyed: false,
                isConsiderConstructionSites: false);

            foreach (var pattern in WallPatterns.PatternsPrimary)
            {
                if (!pattern.IsPass(sameTypeNeighbors))
                {
                    continue;
                }

                if (pattern.IsValidDestroyed)
                {
                    pattern.SetupPhysicsDestroyed(data.PhysicsBody);
                    return;
                }

                // the destroyed wall is not required anymore
                if (IsServer)
                {
                    // destroy this invalid wall after a delay
                    // (as this method might be executed in a foreach enumeration)
                    ServerTimersSystem.AddAction(
                        0.1,
                        () => Server.World.DestroyObject(data.GameObject));
                }

                return;
            }
        }