public ResourceType(ResourceTypeInfo info, World world) { Info = info; Variants = new Dictionary <string, ISpriteSequence>(); foreach (var v in info.Sequences) { var seq = world.Map.Rules.Sequences.GetSequence(Info.Image, v); Variants.Add(v, seq); } }
public ResourceType(ResourceTypeInfo info, World world) { Info = info; Variants = new Dictionary <string, Sprite[]>(); foreach (var v in info.Sequences) { var seq = world.Map.Rules.Sequences.GetSequence(Info.Image, v); var sprites = Exts.MakeArray(seq.Length, x => seq.GetSprite(x)); Variants.Add(v, sprites); } }
public int SetResource(WorldRenderer wr, ResourceTypeInfo resource) { terrainOrResourceCell = wr.Viewport.ViewToWorld(wr.Viewport.WorldToViewPx(Viewport.LastMousePos)); Type = EditorCursorType.Resource; Resource = resource; Actor = null; TerrainTemplate = null; terrainOrResourceDirty = true; return(++CurrentToken); }
public void Clear(int token) { if (token != CurrentToken) { return; } Type = EditorCursorType.None; Actor = null; TerrainTemplate = null; Resource = null; }
public int SetActor(WorldRenderer wr, ActorInfo actor, PlayerReference owner) { var ios = actor.TraitInfoOrDefault <IOccupySpaceInfo>(); var buildingInfo = ios as BuildingInfo; actorCenterOffset = buildingInfo?.CenterOffset(world) ?? WVec.Zero; actorSharesCell = ios != null && ios.SharesCell; actorSubCell = SubCell.Invalid; // Enforce first entry of ValidOwnerNames as owner if the actor has RequiresSpecificOwners var ownerName = owner.Name; var specificOwnerInfo = actor.TraitInfoOrDefault <RequiresSpecificOwnersInfo>(); if (specificOwnerInfo != null && !specificOwnerInfo.ValidOwnerNames.Contains(ownerName)) { ownerName = specificOwnerInfo.ValidOwnerNames.First(); } var reference = new ActorReference(actor.Name); reference.Add(new OwnerInit(ownerName)); reference.Add(new FactionInit(owner.Faction)); var worldPx = wr.Viewport.ViewToWorldPx(Viewport.LastMousePos) - wr.ScreenPxOffset(actorCenterOffset); var cell = wr.Viewport.ViewToWorld(wr.Viewport.WorldToViewPx(worldPx)); reference.Add(new LocationInit(cell)); if (ios != null && ios.SharesCell) { actorSubCell = editorLayer.FreeSubCellAt(cell); if (actorSubCell != SubCell.Invalid) { reference.Add(new SubCellInit(actorSubCell)); } } if (actor.HasTraitInfo <IFacingInfo>()) { reference.Add(new FacingInit(info.PreviewFacing)); } Type = EditorCursorType.Actor; Actor = new EditorActorPreview(wr, null, reference, owner); TerrainTemplate = null; Resource = null; return(++CurrentToken); }