Content.Client/GameObjects/EntitySystems/ConstructionSystem.cs
/// <summary>
/// Creates a construction ghost at the given location.
/// </summary>
Creates a construction ghost at the given location.
Creates a construction ghost at the given location .
public void SpawnGhost(ConstructionPrototype prototype, EntityCoordinates loc, Direction dir)
        {
            var user = _playerManager.LocalPlayer?.ControlledEntity;
            if (user == null || GhostPresent(loc) || !user.InRangeUnobstructed(loc, 20f, ignoreInsideBlocker:prototype.CanBuildInImpassable))
            {
                return;
            }
            foreach (var condition in prototype.Conditions)
            {
                if (!condition.Condition(user, loc, dir))
                    return;
            }
            var ghost = EntityManager.SpawnEntity("constructionghost", loc);
            var comp = ghost.GetComponent<ConstructionGhostComponent>();
            comp.Prototype = prototype;
            comp.GhostID = _nextId++;
            ghost.Transform.LocalRotation = dir.ToAngle();
            _ghosts.Add(comp.GhostID, comp);
            var sprite = ghost.GetComponent<SpriteComponent>();
            sprite.Color = new Color(48, 255, 48, 128);
            sprite.AddBlankLayer(0); 
            sprite.LayerSetSprite(0, prototype.Icon);
            sprite.LayerSetShader(0, "unshaded");
            sprite.LayerSetVisible(0, true);
        }
public void SpawnGhost ( ConstructionPrototype prototype , EntityCoordinates loc , Direction dir ) { var user = _playerManager . LocalPlayer ? . ControlledEntity ; if ( user == null || GhostPresent ( loc ) || ! user . InRangeUnobstructed ( loc , 20f , ignoreInsideBlocker : prototype . CanBuildInImpassable ) ) { return ; } foreach ( var condition in prototype . Conditions ) { if ( ! condition . Condition ( user , loc , dir ) ) return ; } var ghost = EntityManager . SpawnEntity ( " " , loc ) ; var comp = ghost . GetComponent < ConstructionGhostComponent > ( ) ; comp . Prototype = prototype ; comp . GhostID = _nextId ++ ; ghost . Transform . LocalRotation = dir . ToAngle ( ) ; _ghosts . Add ( comp . GhostID , comp ) ; var sprite = ghost . GetComponent < SpriteComponent > ( ) ; sprite . Color = new Color ( 48 , 255 , 48 , 128 ) ; sprite . AddBlankLayer ( 0 ) ; sprite . LayerSetSprite ( 0 , prototype . Icon ) ; sprite . LayerSetShader ( 0 , " " ) ; sprite . LayerSetVisible ( 0 , true ) ; }
Creates a construction ghost at the given location.
Creates a construction ghost at the given location .
// This InRangeUnobstructed should probably be replaced with "is there something blocking us in that tile?" // There is no way to actually check if this already exists, so we blindly insert a new one
prototype
ConstructionPrototype
loc
EntityCoordinates
dir
Direction