Beispiel #1
0
        protected override void ServerInitialize(ServerInitializeData data)
        {
            base.ServerInitialize(data);

            var worldObject = data.GameObject;
            var tile        = worldObject.OccupiedTile;
            var protoWall   = data.PublicState.OriginalProtoObjectWall;

            if (!ProtoObjectWallHelper.SharedIsDestroyedWallRequired(tile, protoWall))
            {
                // schedule destruction of this wall object
                ServerTimersSystem.AddAction(delaySeconds: 0.1,
                                             () =>
                {
                    if (!worldObject.IsDestroyed &&
                        !ProtoObjectWallHelper.SharedIsDestroyedWallRequired(
                            tile,
                            protoWall))
                    {
                        Server.World.DestroyObject(worldObject);
                    }
                });
                return;
            }

            SharedWallConstructionRefreshHelper.SharedRefreshNeighborObjects(
                worldObject.OccupiedTile,
                isDestroy: false);
        }
Beispiel #2
0
        protected override void ClientInitialize(ClientInitializeData data)
        {
            // don't use base implementation
            //base.ClientInitialize(data);

            this.ClientAddAutoStructurePointsBar(data);

            var worldObject = data.GameObject;
            var clientState = GetClientState(worldObject);

            // create renderers
            clientState.Renderer = Client.Rendering.CreateSpriteRenderer(worldObject);

            ProtoObjectWallHelper.ClientRefreshRenderer(data.GameObject);

            SharedWallConstructionRefreshHelper.SharedRefreshNeighborObjects(
                data.GameObject.OccupiedTile,
                isDestroy: false);
        }
        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;
                }
            }
        }
Beispiel #4
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;
            }
        }
 public override void ClientSetupBlueprint(
     Tile tile,
     IClientBlueprint blueprint)
 {
     ProtoObjectWallHelper.ClientSetupBlueprint(this, tile, blueprint);
 }
 public void ClientRefreshRenderer(IStaticWorldObject worldObject)
 {
     ProtoObjectWallHelper.ClientRefreshRenderer(worldObject);
 }