internal Actor(World world, string name, TypeDictionary initDict) { var init = new ActorInitializer(this, initDict); World = world; ActorID = world.NextAID(); if (initDict.Contains <OwnerInit>()) { Owner = init.Get <OwnerInit, Player>(); } occupySpace = Lazy.New(() => TraitOrDefault <IOccupySpace>()); if (name != null) { if (!Rules.Info.ContainsKey(name.ToLowerInvariant())) { throw new NotImplementedException("No rules definition for unit {0}".F(name.ToLowerInvariant())); } Info = Rules.Info[name.ToLowerInvariant()]; foreach (var trait in Info.TraitsInConstructOrder()) { AddTrait(trait.Create(init)); } } Move = Lazy.New(() => TraitOrDefault <IMove>()); Facing = Lazy.New(() => TraitOrDefault <IFacing>()); Size = Lazy.New(() => { var si = Info.Traits.GetOrDefault <SelectableInfo>(); if (si != null && si.Bounds != null) { return(new int2(si.Bounds[0], si.Bounds[1])); } return(TraitsImplementing <IAutoSelectionSize>().Select(x => x.SelectionSize(this)).FirstOrDefault()); }); if (this.HasTrait <RevealsShroud>()) { Sight = new Shroud.ActorVisibility { range = this.Trait <RevealsShroud>().RevealRange, vis = Shroud.GetVisOrigins(this).ToArray() }; } ApplyIRender = (x, wr) => x.Render(this, wr); ApplyRenderModifier = (m, p, wr) => p.ModifyRender(this, wr, m); Bounds = Cached.New(() => CalculateBounds(false)); ExtendedBounds = Cached.New(() => CalculateBounds(true)); }
public bool IsVisible(Actor self, Player byPlayer) { return(byPlayer == null || Shroud.GetVisOrigins(self).Any(o => byPlayer.Shroud.IsVisible(o))); }
public bool IsVisible(Actor self) { return(Shroud.GetVisOrigins(self).Any(o => self.World.LocalShroud.IsVisible(o))); }
public void UpdateSight() { Sight.vis = Shroud.GetVisOrigins(this).ToArray(); }