Пример #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;
        }
Пример #5
0
        public override IEnumerable <Gizmo> CompGetGizmosExtra()
        {
            yield return(new Command_Action
            {
                defaultLabel = "TraderShipsSendAway".Translate(),
                defaultDesc = "TraderShipsSendAwayDesc".Translate(),
                action = new Action(SendAway),
                icon = SendAwayTexture,
            });

            if (tradeRequest != null)
            {
                Command_Action command_Action = new Command_Action();
                command_Action.defaultLabel = "CommandFulfillTradeOffer".Translate();
                command_Action.defaultDesc  = "CommandFulfillTradeOfferDesc".Translate();
                command_Action.icon         = TradeCommandTex;
                command_Action.action       = delegate()
                {
                    if (tradeRequest == null)
                    {
                        Log.Error("Attempted to fulfill an unavailable request", false);
                        return;
                    }

                    WindowStack  windowStack = Find.WindowStack;
                    TaggedString text        = "CommandFulfillTradeOfferConfirm".Translate(GenLabel.ThingLabel(tradeRequest.requestedThingDef, null, tradeRequest.requestedCount));

                    windowStack.Add(Dialog_MessageBox.CreateConfirmation(text, delegate() { FulfillTradeRequest(); }, false, null));
                };

                if (!tradeRequest.CanFulfillRequest(tradeShip))
                {
                    command_Action.Disable("CommandFulfillTradeOfferFailInsufficient".Translate(TradeRequestUtility.RequestedThingLabel(tradeRequest.requestedThingDef, tradeRequest.requestedCount)));
                }

                yield return(command_Action);
            }

            if (Prefs.DevMode)
            {
                yield return(new Command_Action
                {
                    defaultLabel = "Dev: randomize sprite",
                    action = delegate()
                    {
                        Color color = sprite.color;
                        sprite = Props.shipgen.CreateSprite();
                        sprite.color = color;
                        sprite.FinishCreating();
                    },
                });

                yield return(new Command_Action
                {
                    defaultLabel = "Dev: randomize color",
                    action = delegate()
                    {
                        sprite.color = ShipSprite.RandomColor();
                        sprite.FinishCreating();
                    },
                });
            }

            yield break;
        }