예제 #1
0
        public ShipSprite CreateSprite()
        {
            ShipgenState state = new ShipgenState();
            ShipSprite   res   = new ShipSprite();

            Apply(state, res);

            res.FinishCreating();

            return(res);
        }
예제 #2
0
        public void Apply(ShipgenState state, ShipSprite sprite)
        {
            foreach (ShipgenStep step in steps)
            {
                step.Apply(state, sprite);
            }

            if (TraderShips.settings.colors)
            {
                sprite.color = ShipSprite.RandomColor();
            }
        }
예제 #3
0
        public override void Apply(ShipgenState state, ShipSprite sprite)
        {
            ShipSpritePartDef def = DefDatabase <ShipSpritePartDef> .AllDefs.Where(x => x.category == category).RandomElement();

            sprite.parts.Add(new ShipSpritePart()
            {
                def      = def,
                angle    = angle.RandomInRange,
                distance = state.distance,
                offset   = state.offset + offset,
                layer    = layer,
            });
        }
예제 #4
0
        public override void Apply(ShipgenState state, ShipSprite sprite)
        {
            if (Rand.Value > chance)
            {
                return;
            }

            Vector2 storedOffset   = state.offset;
            float   storedDistance = state.distance;

            state.offset   += offset + new Vector2(offsetVarianceX.RandomInRange, offsetVarianceY.RandomInRange);
            state.distance += distance.RandomInRange;
            shipgen.Apply(state, sprite);
            state.offset   = storedOffset;
            state.distance = storedDistance;
        }