public override void DoImpact(Target target, Actor firedBy, IEnumerable<int> damageModifiers) { if (!target.IsValidFor(firedBy)) return; var pos = target.CenterPosition; var world = firedBy.World; var targetTile = world.Map.CellContaining(pos); var isValid = IsValidImpact(pos, firedBy); if ((!world.Map.Contains(targetTile)) || (!isValid)) return; var palette = ExplosionPalette; if (UsePlayerPalette) palette += firedBy.Owner.InternalName; var explosion = Explosions.RandomOrDefault(Game.CosmeticRandom); if (Image != null && explosion != null) world.AddFrameEndTask(w => w.Add(new SpriteEffect(pos, w, Image, explosion, palette))); var impactSound = ImpactSounds.RandomOrDefault(Game.CosmeticRandom); if (impactSound != null) Game.Sound.Play(impactSound, pos); }
static Actor ChooseHelipad(Actor self) { var rearmBuildings = self.Info.Traits.Get<HelicopterInfo>().RearmBuildings; return self.World.Actors.Where( a => a.Owner == self.Owner ).FirstOrDefault( a => rearmBuildings.Contains(a.Info.Name) && !Reservable.IsReserved(a)); }
public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued) { if (order.OrderID == "RepairBridge") return new Order(order.OrderID, self, queued) { TargetActor = target.Actor }; return null; }
public void GuardTarget(Actor self, Target target) { self.SetTargetLine(target, Color.Yellow); var range = WDist.FromCells(target.Actor.Info.Traits.Get<GuardableInfo>().Range); self.QueueActivity(false, new AttackMoveActivity(self, self.Trait<IMove>().MoveFollow(self, target, WDist.Zero, range))); }
public override Activity Tick(Actor self) { switch (state) { case State.Wait: return this; case State.Turn: state = State.DragIn; return Util.SequenceActivities(new Turn(112), this); case State.DragIn: state = State.Dock; return Util.SequenceActivities(new Drag(startDock, endDock, 12), this); case State.Dock: ru.PlayCustomAnimation(self, "dock", () => { ru.PlayCustomAnimRepeating(self, "dock-loop"); state = State.Loop; }); state = State.Wait; return this; case State.Loop: if (!proc.IsInWorld || proc.IsDead() || harv.TickUnload(self, proc)) state = State.Undock; return this; case State.Undock: ru.PlayCustomAnimBackwards(self, "dock", () => state = State.DragOut); state = State.Wait; return this; case State.DragOut: return Util.SequenceActivities(new Drag(endDock, startDock, 12), NextActivity); } throw new InvalidOperationException("Invalid harvester dock state"); }
public void SetUp() { Location location = new Location (null, new Point (5, 5)); actor = new MockActor (location); item = new MockItem (location); }
void DoTransform(Actor self) { // Hack: repeat the first frame of the make anim instead // of flashing the full structure for a frame if (rb != null) rb.PlayCustomAnim(self, "make"); self.World.AddFrameEndTask(w => { var selected = w.Selection.Contains(self); self.Destroy(); foreach (var s in sounds) Sound.PlayToPlayer(self.Owner, s, self.CenterLocation); var init = new TypeDictionary { new LocationInit( self.Location + offset ), new OwnerInit( self.Owner ), new FacingInit( facing ), }; if (self.HasTrait<Health>()) init.Add( new HealthInit( self.Trait<Health>().HPFraction )); var a = w.CreateActor( actor, init ); if (selected) w.Selection.Add(w, a); }); }
public int DrawCostume(VirtScreen vs, int numStrips, Actor actor, bool drawToBackBuf) { var pixelsNavigator = new PixelNavigator(vs.Surfaces[drawToBackBuf ? 1 : 0]); pixelsNavigator.OffsetX(vs.XStart); ActorX += (vs.XStart & 7); _w = vs.Width; _h = vs.Height; pixelsNavigator.OffsetX(-(vs.XStart & 7)); startNav = new PixelNavigator(pixelsNavigator); if (_vm.Game.Version <= 1) { _xmove = 0; _ymove = 0; } else if (_vm.Game.IsOldBundle) { _xmove = -72; _ymove = -100; } else { _xmove = _ymove = 0; } int result = 0; for (int i = 0; i < 16; i++) result |= DrawLimb(actor, i); return result; }
public override void Activate(Actor self, Order order) { var enterCell = self.World.ChooseRandomEdgeCell(); var plane = self.World.CreateActor("u2", new TypeDictionary { new LocationInit( enterCell ), new OwnerInit( self.Owner ), new FacingInit( Util.GetFacing(order.TargetLocation - enterCell, 0) ), new AltitudeInit( Rules.Info["u2"].Traits.Get<PlaneInfo>().CruiseAltitude ), }); plane.CancelActivity(); plane.QueueActivity(Fly.ToCell(order.TargetLocation)); plane.QueueActivity(new CallFunc(() => plane.World.AddFrameEndTask( w => { var camera = w.CreateActor("camera", new TypeDictionary { new LocationInit( order.TargetLocation ), new OwnerInit( self.Owner ), }); camera.QueueActivity(new Wait(25 * (Info as SpyPlanePowerInfo).RevealTime)); camera.QueueActivity(new RemoveSelf()); }))); plane.QueueActivity(new FlyOffMap()); plane.QueueActivity(new RemoveSelf()); }
public UnloadCargo(Actor self, bool unloadAll) { this.self = self; cargo = self.Trait<Cargo>(); cloak = self.TraitOrDefault<Cloak>(); this.unloadAll = unloadAll; }
public UpgradeActorsNear(Actor self, UpgradeActorsNearInfo info) { this.info = info; this.self = self; cachedRange = info.Range; cachedVRange = info.MaximumVerticalOffset; }
public override void Activate(Actor self, Order order) { // TODO: Reveal submarines // Should this play for all players? Sound.Play("sonpulse.aud"); }
public static bool CanPlaceBuilding(this World world, string name, BuildingInfo building, int2 topLeft, Actor toIgnore) { var res = world.WorldActor.Trait<ResourceLayer>(); return FootprintUtils.Tiles(name, building, topLeft).All( t => world.Map.IsInMap(t.X, t.Y) && res.GetResource(t) == null && world.IsCellBuildable(t, building.WaterBound, toIgnore)); }
public ShroudPalette(Actor self, ShroudPaletteInfo info) { // TODO: This shouldn't rely on a base palette var wr = self.World.WorldRenderer; var pal = wr.GetPalette("terrain"); wr.AddPalette(info.Name, new Palette(pal, new ShroudPaletteRemap(info.IsFog))); }
protected override void OnInside(Actor self) { if (health.DamageState == DamageState.Undamaged) return; target.InflictDamage(self, -health.MaxHP, null); self.Dispose(); }
public override void Activate(Actor collector) { var actorsInRange = self.World.FindActorsInCircle(self.CenterPosition, info.Range) .Where(a => a != self && a != collector && a.Owner == collector.Owner && AcceptsUpgrade(a)); if (info.MaxExtraCollectors > -1) actorsInRange = actorsInRange.Take(info.MaxExtraCollectors); collector.World.AddFrameEndTask(w => { foreach (var a in actorsInRange.Append(collector)) { if (!a.IsInWorld || a.IsDead) continue; var um = a.TraitOrDefault<UpgradeManager>(); foreach (var u in info.Upgrades) { if (info.Duration > 0) { if (um.AcknowledgesUpgrade(a, u)) um.GrantTimedUpgrade(a, u, info.Duration); } else { if (um.AcceptsUpgrade(a, u)) um.GrantUpgrade(a, u, this); } } } }); base.Activate(collector); }
public override Activity Tick(Actor self) { switch (dockingState) { case State.Wait: return this; case State.Turn: dockingState = State.Dock; if (IsDragRequired) return ActivityUtils.SequenceActivities(new Turn(self, DockAngle), new Drag(self, StartDrag, EndDrag, DragLength), this); return ActivityUtils.SequenceActivities(new Turn(self, DockAngle), this); case State.Dock: if (Refinery.IsInWorld && !Refinery.IsDead) foreach (var nd in Refinery.TraitsImplementing<INotifyDocking>()) nd.Docked(Refinery, self); return OnStateDock(self); case State.Loop: if (!Refinery.IsInWorld || Refinery.IsDead || Harv.TickUnload(self, Refinery)) dockingState = State.Undock; return this; case State.Undock: return OnStateUndock(self); case State.Complete: if (Refinery.IsInWorld && !Refinery.IsDead) foreach (var nd in Refinery.TraitsImplementing<INotifyDocking>()) nd.Undocked(Refinery, self); Harv.LastLinkedProc = Harv.LinkedProc; Harv.LinkProc(self, null); if (IsDragRequired) return ActivityUtils.SequenceActivities(new Drag(self, EndDrag, StartDrag, DragLength), NextActivity); return NextActivity; } throw new InvalidOperationException("Invalid harvester dock state"); }
public Minelayer(Actor self) { this.self = self; var tileset = self.World.Map.Tileset.ToLowerInvariant(); tile = self.World.Map.Rules.Sequences.GetSequence("overlay", "build-valid-{0}".F(tileset)).GetSprite(0); }
public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued) { if (order.OrderID == "DeployTransform") return new Order(order.OrderID, self, queued); return null; }
public override Activity Tick(Actor self) { if (IsCanceled || !target.IsValidFor(self)) return NextActivity; // Inside the target annulus, so we're done var insideMaxRange = maxRange.Range > 0 && target.IsInRange(plane.CenterPosition, maxRange); var insideMinRange = minRange.Range > 0 && target.IsInRange(plane.CenterPosition, minRange); if (insideMaxRange && !insideMinRange) return NextActivity; // Close enough (ported from old code which checked length against sqrt(50) px) var d = target.CenterPosition - self.CenterPosition; if (d.HorizontalLengthSquared < 91022) return NextActivity; var desiredFacing = Util.GetFacing(d, plane.Facing); // Don't turn until we've reached the cruise altitude if (plane.CenterPosition.Z < plane.Info.CruiseAltitude.Range) desiredFacing = plane.Facing; FlyToward(self, plane, desiredFacing, plane.Info.CruiseAltitude); return this; }
public Building(ActorInitializer init) { this.self = init.self; this.topLeft = init.Get<LocationInit,int2>(); this.Info = self.Info.Traits.Get<BuildingInfo>(); this.PlayerPower = init.self.Owner.PlayerActor.Trait<PowerManager>(); }
public Transforms(ActorInitializer init, TransformsInfo info) { self = init.self; this.info = info; bi = self.World.Map.Rules.Actors[info.IntoActor].Traits.GetOrDefault<BuildingInfo>(); race = init.Contains<RaceInit>() ? init.Get<RaceInit, string>() : self.Owner.Country.Race; }
public override Activity Tick(Actor self) { if (self.World.Map.DistanceAboveTerrain(self.CenterPosition).Length <= 0) { if (info.ExplosionWeapon != null) { // Use .FromPos since this actor is killed. Cannot use Target.FromActor info.ExplosionWeapon.Impact(Target.FromPos(self.CenterPosition), self, Enumerable.Empty<int>()); } self.Dispose(); return null; } if (info.Spins) { spin += acceleration; aircraft.Facing = (aircraft.Facing + spin) % 256; } var move = info.Moves ? aircraft.FlyStep(aircraft.Facing) : WVec.Zero; move -= new WVec(WDist.Zero, WDist.Zero, info.Velocity); aircraft.SetPosition(self, aircraft.CenterPosition + move); return this; }
protected override void OnInside(Actor self) { self.World.AddFrameEndTask(w => { if (target.IsDead) return; if (cloak != null && cloak.Info.UncloakOnDemolish) cloak.Uncloak(); for (var f = 0; f < flashes; f++) w.Add(new DelayedAction(flashesDelay + f * flashInterval, () => w.Add(new FlashTarget(target, ticks: flashDuration)))); w.Add(new DelayedAction(delay, () => { if (target.IsDead) return; var modifiers = target.TraitsImplementing<IDamageModifier>() .Concat(self.Owner.PlayerActor.TraitsImplementing<IDamageModifier>()) .Select(t => t.GetDamageModifier(self, null)); if (Util.ApplyPercentageModifiers(100, modifiers) > 0) demolishables.Do(d => d.Demolish(target, self)); })); }); }
public IActivity Tick(Actor self) { var targetAltitude = self.Info.Traits.Get<PlaneInfo>().CruiseAltitude; if (isCanceled || !self.World.Map.IsInMap(self.Location)) return NextActivity; FlyUtil.Fly(self, targetAltitude); return this; }
public FallToEarth(Actor self, FallsToEarthInfo info) { this.info = info; aircraft = self.Trait<Aircraft>(); if (info.Spins) acceleration = self.World.SharedRandom.Next(2) * 2 - 1; }
public IActivity Tick(Actor self) { if (target == null || target.IsDead) return NextActivity; self.World.AddFrameEndTask(w => w.Add(new DelayedAction(25 * 2, () => target.InflictDamage(self, target.Health, null)))); return NextActivity; }
public void Tick(Actor self) { if (!validTileset) return; t += info.RotationStep; }
public override void Activate(Actor self, Order order, SupportPowerManager manager) { base.Activate(self, order, manager); var wsb = self.TraitOrDefault<WithSpriteBody>(); if (wsb != null && wsb.DefaultAnimation.HasSequence(info.GrantUpgradeSequence)) wsb.PlayCustomAnimation(self, info.GrantUpgradeSequence); Game.Sound.Play(info.GrantUpgradeSound, self.World.Map.CenterOfCell(order.TargetLocation)); foreach (var a in UnitsInRange(order.TargetLocation)) { var um = a.TraitOrDefault<UpgradeManager>(); if (um == null) continue; foreach (var u in info.Upgrades) { if (info.Duration > 0) { if (um.AcknowledgesUpgrade(a, u)) um.GrantTimedUpgrade(a, u, info.Duration); } else { if (um.AcceptsUpgrade(a, u)) um.GrantUpgrade(a, u, this); } } } }
public void RenderAfterWorld(WorldRenderer wr, Actor self) { Color trailStart = TrailColor; Color trailEnd = Color.FromArgb(trailStart.A - 255 / TrailLength, trailStart.R, trailStart.G, trailStart.B); // LocalPlayer is null on shellmap ShroudRenderer shroud = null; if (self.World.LocalPlayer != null) shroud = self.World.LocalPlayer.Shroud; for (int i = positions.Count - 1; i >= 1; --i) { var conPos = positions[i]; var nextPos = positions[i - 1]; if (shroud == null || shroud.IsVisible(OpenRA.Traits.Util.CellContaining(conPos)) || shroud.IsVisible(OpenRA.Traits.Util.CellContaining(nextPos))) { Game.Renderer.LineRenderer.DrawLine(conPos, nextPos, trailStart, trailEnd); trailStart = trailEnd; trailEnd = Color.FromArgb(trailStart.A - 255 / positions.Count, trailStart.R, trailStart.G, trailStart.B); } } }
public GrantExternalConditionCrateAction(Actor self, GrantExternalConditionCrateActionInfo info) : base(self, info) { this.self = self; this.info = info; }
public void PerformUpdate() { List <RoomActor> ActorsToUpdate = new List <RoomActor>(); List <RoomActor> ActorsToRemove = new List <RoomActor>(); // Copy collection Dictionary <uint, RoomActor> ActorsCopy = new Dictionary <uint, RoomActor>(); List <RoomActor>[,] NewUserGrid = new List <RoomActor> [mCachedModel.Heightmap.SizeX, mCachedModel.Heightmap.SizeY]; lock (mActorSyncRoot) { foreach (KeyValuePair <uint, RoomActor> CopyItem in mActors) { ActorsCopy.Add(CopyItem.Key, CopyItem.Value); } } foreach (RoomActor Actor in ActorsCopy.Values) { // If the room is unloaded, allow no actors if (mUnloaded) { ActorsToRemove.Add(Actor); continue; } // The idle time is increased in every step. if (Actor.Type == RoomActorType.UserCharacter) { Actor.IncreaseIdleTime(Actor.ReferenceId == Info.OwnerId); } // If this is a bot, allow the brain to process this update tick. if (Actor.Type == RoomActorType.AiBot) { ((Bot)Actor.ReferenceObject).Brain.PerformUpdate(this); } // Remove any walking statusses (they will be re-applied below if neccessary) if (Actor.UserStatusses.ContainsKey("mv")) { Actor.RemoveStatus("mv"); Actor.UpdateNeeded = true; } // Update actor position if neccessary if (Actor.PositionToSet != null) { // Check if the new position is in the door if (Actor.Type == RoomActorType.UserCharacter && Actor.PositionToSet.X == mCachedModel.DoorPosition.X && Actor.PositionToSet.Y == mCachedModel.DoorPosition.Y) { ActorsToRemove.Add(Actor); continue; } // Update the actual position Actor.Position = new Vector3(Actor.PositionToSet.X, Actor.PositionToSet.Y, (Math.Round(GetUserStepHeight(Actor.PositionToSet), 1))); Actor.PositionToSet = null; // Handle any "MoveToAndInteract" events if this was the last step if (!Actor.IsMoving && Actor.MoveToAndInteract > 0 && Actor.Type == RoomActorType.UserCharacter) { Item Item = GetItem(Actor.MoveToAndInteract); if (Item != null) { ItemEventDispatcher.InvokeItemEventHandler(SessionManager.GetSessionByCharacterId( Actor.ReferenceId), Item, this, ItemEventType.Interact, Actor.MoveToAndInteractData); } Actor.MoveToAndInteract = 0; Actor.MoveToAndInteractData = 0; } } // If there are more steps to be made, handle it. if (Actor.IsMoving) { // Check if moving to door if (!Actor.IsLeavingRoom && Actor.Pathfinder.Target.X == mCachedModel.DoorPosition.X && Actor.Pathfinder.Target.Y == mCachedModel.DoorPosition.Y) { Actor.IsLeavingRoom = true; } // Get the next step from the pathfinder Vector2 NextStep = Actor.GetNextStep(); // If the user is leaving and has exceeded 11 steps, help him out by instantly // removing them. if (Actor.LeaveStepsTaken >= 11) { ActorsToRemove.Add(Actor); continue; } // If the pathfinder reports no more steps to be made, this is the last step. bool LastStep = !Actor.IsMoving; // Check that the next step is valid and allowed if (NextStep != null && ((!Actor.ClippingEnabled && IsValidPosition(NextStep)) || IsValidStep(Actor.Position.GetVector2(), NextStep, LastStep, NewUserGrid))) { // Update "mv" status Actor.SetStatus("mv", NextStep.X + "," + NextStep.Y + "," + (Math.Round(GetUserStepHeight(NextStep), 1)).ToString().Replace(',', '.')); Actor.PositionToSet = NextStep; // Update new/temporary grid with our new move to position if (NewUserGrid[NextStep.X, NextStep.Y] == null) { NewUserGrid[NextStep.X, NextStep.Y] = new List <RoomActor>(); } NewUserGrid[NextStep.X, NextStep.Y].Add(Actor); // Remove any "sit" statusses if (Actor.UserStatusses.ContainsKey("sit")) { Actor.RemoveStatus("sit"); } // Remove any "lay" statusses if (Actor.UserStatusses.ContainsKey("lay")) { Actor.RemoveStatus("lay"); } // Update rotation Actor.BodyRotation = Rotation.Calculate(Actor.Position.GetVector2(), NextStep); Actor.HeadRotation = Actor.BodyRotation; // Request update for next @B cycle Actor.UpdateNeeded = true; } else { // Invalid step: tell pathfinder to stop and mark current position on temporary grid Actor.StopMoving(); if (NewUserGrid[NextStep.X, NextStep.Y] == null) { NewUserGrid[NextStep.X, NextStep.Y] = new List <RoomActor>(); } NewUserGrid[NextStep.X, NextStep.Y].Add(Actor); } } else { if (NewUserGrid[Actor.Position.X, Actor.Position.Y] == null) { NewUserGrid[Actor.Position.X, Actor.Position.Y] = new List <RoomActor>(); } NewUserGrid[Actor.Position.X, Actor.Position.Y].Add(Actor); } // If the actor is leaving and has stopped walking, help them out by removing them. if (!Actor.IsMoving && Actor.IsLeavingRoom && Actor.Type == RoomActorType.UserCharacter) { ActorsToRemove.Add(Actor); continue; } // Update status (apply any sit/lay/effect) UpdateActorStatus(Actor); // Add this actor to the update list if this has been requested if (Actor.UpdateNeeded) { ActorsToUpdate.Add(Actor); Actor.UpdateNeeded = false; } } // Remove all actors that need to be removed foreach (RoomActor Actor in ActorsToRemove) { lock (mActorSyncRoot) { if (ActorsToUpdate.Contains(Actor)) { ActorsToUpdate.Remove(Actor); } } switch (Actor.Type) { default: RemoveActorFromRoom(Actor.Id); break; case RoomActorType.UserCharacter: HardKickUser(Actor.ReferenceId); break; } } // Send update list (if there are any updates) to room if (ActorsToUpdate.Count > 0) { BroadcastMessage(RoomUserStatusListComposer.Compose(ActorsToUpdate)); } // Update tick on all items -- List <Item> ItemCopy = null; lock (mItemSyncRoot) { ItemCopy = mItems.Values.ToList(); } foreach (Item Item in ItemCopy) { Item.Update(this); } // Invalidate door position NewUserGrid[mCachedModel.DoorPosition.X, mCachedModel.DoorPosition.Y] = null; // Update user grid to our new version lock (mActorSyncRoot) { mUserGrid = NewUserGrid; } if (mMusicController != null && mMusicController.IsPlaying) { mMusicController.Update(this); } }
bool AcceptsCondition(Actor a) { return(a.TraitsImplementing <ExternalCondition>() .Any(t => t.Info.Condition == info.Condition && t.CanGrantCondition(self))); }
public void Repair(Actor repairer) { repairDirections = Bridge.GetHut(0) != this && Bridge.GetHut(1) != this ? 2 : 1; Bridge.Do((b, d) => b.Repair(repairer, d, () => repairDirections--)); }
public bool IsValidTarget(ActorInfo actorInfo, Actor saboteur) { return(false); } // TODO: bridges don't support frozen under fog
public override int GetSelectionShares(Actor collector) { return(AcceptsCondition(collector) ? info.SelectionShares : 0); }
/// <summary> /// Adds a HighlitingTile to an actor. /// </summary> /// <param name="toPlaceOn">The actor to where the HighlightingTile should be added to.</param> /// <returns>The Highliting Tile.</returns> protected abstract HighlitingTile <T> AddHighlitingTile(Actor toPlaceOn);
void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) { playerResources = newOwner.PlayerActor.Trait <PlayerResources>(); PlayAnimation(self); }
protected override void TraitEnabled(Actor self) { PlayAnimation(self); }
/// <summary> /// Adds a MouseControlComponent to an actor. /// </summary> /// <param name="toPlaceOn">The actor to where the MouseControlComponent should be added to.</param> /// <returns>The MouseControlComponent</returns> protected virtual MouseControlComponent <T> AddMouseControl(Actor toPlaceOn) => toPlaceOn.AddComponent <MouseControlComponent <T> >();
public ActorMover(Actor target) { this.Target = target; }
public override IEnumerable <Target> GetTargets(Actor self) { yield return(Target.FromCell(self.Location)); }
public override Activity Tick(Actor self) { if (IsCanceled || NextActivity != null) { return(NextActivity); } var harv = self.Trait <Harvester>(); if (harv.IsFull) { return(Util.SequenceActivities(new DeliverResources(), NextActivity)); } var harvInfo = self.Info.Traits.Get <HarvesterInfo>(); var mobile = self.Trait <Mobile>(); var mobileInfo = self.Info.Traits.Get <MobileInfo>(); var resLayer = self.World.WorldActor.Trait <ResourceLayer>(); var territory = self.World.WorldActor.TraitOrDefault <ResourceClaimLayer>(); // Find harvestable resources nearby: var path = self.World.WorldActor.Trait <PathFinder>().FindPath( PathSearch.Search(self.World, mobileInfo, self.Owner, true) .WithCustomCost(loc => { // Avoid enemy territory: int safetycost = ( // TODO: calculate weapons ranges of units and factor those in instead of hard-coding 8. from u in self.World.FindUnitsInCircle(loc.ToPPos(), Game.CellSize * 8) where !u.Destroyed where self.Owner.Stances[u.Owner] == Stance.Enemy select Math.Max(0, 64 - (loc - u.Location).LengthSquared) ).Sum(); return(safetycost); }) .WithHeuristic(loc => { // Avoid this cell: if (avoidCell.HasValue && loc == avoidCell.Value) { return(1); } // Don't harvest out of range: int distSquared = (loc - (harv.LastOrderLocation ?? harv.LinkedProc.Location)).LengthSquared; if (distSquared > (12 * 12)) { return(int.MaxValue); } // Get the resource at this location: var resType = resLayer.GetResource(loc); if (resType == null) { return(1); } // Can the harvester collect this kind of resource? if (!harvInfo.Resources.Contains(resType.info.Name)) { return(1); } if (territory != null) { // Another harvester has claimed this resource: ResourceClaim claim; if (territory.IsClaimedByAnyoneElse(self, loc, out claim)) { return(1); } } return(0); }) .FromPoint(self.Location) ); if (path.Count == 0) { if (!harv.IsEmpty) { return(new DeliverResources()); } else { // Get out of the way if we are: harv.UnblockRefinery(self); int randFrames = 125 + self.World.SharedRandom.Next(-35, 35); if (NextActivity != null) { return(Util.SequenceActivities(NextActivity, new Wait(randFrames), new FindResources())); } else { return(Util.SequenceActivities(new Wait(randFrames), new FindResources())); } } } // Attempt to claim a resource as ours: if (territory != null) { if (!territory.ClaimResource(self, path[0])) { return(Util.SequenceActivities(new Wait(25), new FindResources())); } } // If not given a direct order, assume ordered to the first resource location we find: if (harv.LastOrderLocation == null) { harv.LastOrderLocation = path[0]; } self.SetTargetLine(Target.FromCell(path[0]), Color.Red, false); return(Util.SequenceActivities(mobile.MoveTo(path[0], 1), new HarvestResource(), new FindResources())); }
public ActionUseExit(Actor actor, Point exitPoint, RogueGame game) : base(actor, game) { m_ExitPoint = exitPoint; }
protected virtual bool AllowIdleAnimation(Actor self) { return(info.IdleAnimations.Length > 0); }
public string VoicePhraseForOrder(Actor self, Order order) { return(info.Voice); }
protected virtual string NormalizeInfantrySequence(Actor self, string baseSequence) { return(baseSequence); }
public void Attacking(Actor self, Target target, Armament a, Barrel barrel) { Attacking(self, target); }
void INotifyActorDisposing.Disposing(Actor self) { // Invalidate the frozen actor (which exists if this actor was captured from an enemy) // for the current owner frozenStates[self.Owner].FrozenActor.Invalidate(); }
public DemoTruck(Actor self, DemoTruckInfo info) { this.info = info; }
IEnumerable <Rectangle> IRenderModifier.ModifyScreenBounds(Actor self, WorldRenderer wr, IEnumerable <Rectangle> bounds) { return(bounds); }
static void Explode(Actor self) { self.World.AddFrameEndTask(w => self.InflictDamage(self, int.MaxValue, null)); }
IEnumerable <IRenderable> IRenderModifier.ModifyRender(Actor self, WorldRenderer wr, IEnumerable <IRenderable> r) { return(IsVisible(self, self.World.RenderPlayer) || isRendering ? r : SpriteRenderable.None); }
void UpdateFrozenActor(Actor self, FrozenActor frozenActor, int playerIndex) { VisibilityHash |= 1 << (playerIndex % 32); frozenActor.RefreshState(); }