public ShipSprite CreateSprite() { ShipgenState state = new ShipgenState(); ShipSprite res = new ShipSprite(); Apply(state, res); res.FinishCreating(); return(res); }
public void Apply(ShipgenState state, ShipSprite sprite) { foreach (ShipgenStep step in steps) { step.Apply(state, sprite); } if (TraderShips.settings.colors) { sprite.color = ShipSprite.RandomColor(); } }
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, }); }
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; }