public override bool ShouldExecute() { if (cooldownUntilMs > entity.World.ElapsedMilliseconds || failureTime > entity.World.ElapsedMilliseconds) { return(false); } prog = entity.GetBehavior <EntityBehaviorProgram>(); if (prog == null || prog.dormant || !prog.CheckArea()) { return(false); } if (entity.LeftHandItemSlot.Itemstack?.Collectible?.CombustibleProps?.BurnDuration == null || entity.LeftHandItemSlot.Itemstack?.Collectible?.CombustibleProps?.BurnTemperature < 200) { return(false); } entityUtil.WalkEntities((prog.workArea.Start + prog.workArea.End) / 2, prog.workArea.Length + prog.workArea.Height + prog.workArea.Width, (ent) => { if (!prog.workArea.ContainsOrTouches(ent.ServerPos.XYZ) || (ally = ent.GetBehavior <EntityBehaviorProgram>()) == null || ally.getEnergy >= refuelpoint) { return(true); } targetEntity = ent; return(false); }); return(targetEntity != null); }
public override bool ShouldExecute() { if (cooldownUntilMs > entity.World.ElapsedMilliseconds || failureTime > entity.World.ElapsedMilliseconds) { return(false); } prog = entity.GetBehavior <EntityBehaviorProgram>(); if (prog == null || prog.dormant) { return(false); } if (!prog.CheckArea() || prog.workStack == null) { return(false); } if (entity.LeftHandItemSlot?.Itemstack != null && entity.LeftHandItemSlot.StackSize >= entity.LeftHandItemSlot.Itemstack.Collectible.MaxStackSize) { return(false); } entityUtil.WalkEntities((prog.workArea.Start + prog.workArea.End) / 2, prog.workArea.Length + prog.workArea.Height + prog.workArea.Width, (ent) => { if ((ent is EntityItem) && prog.workArea.ContainsOrTouches(ent.ServerPos.XYZ) && prog.workStack.Equals(entity.World, (ent as EntityItem).Itemstack, GlobalConstants.IgnoredStackAttributes)) { targetPos = ent.ServerPos.XYZ; return(false); } return(true); }); return(targetPos != null); }
public override bool ShouldExecute() { if (cooldownUntilMs > entity.World.ElapsedMilliseconds || failureTime > entity.World.ElapsedMilliseconds) { return(false); } prog = entity.GetBehavior <EntityBehaviorProgram>(); if (prog == null || prog.dormant || !prog.CheckArea()) { return(false); } entityUtil.WalkEntities((prog.workArea.Start + prog.workArea.End) / 2, prog.workArea.Length + prog.workArea.Height + prog.workArea.Width, (ent) => { if (!prog.workArea.ContainsOrTouches(ent.ServerPos.XYZ) || ent.GetBehavior <EntityBehaviorProgram>() == null) { return(true); } EntityBehaviorHealth bh = ent.GetBehavior <EntityBehaviorHealth>(); if (bh == null || bh.Health >= bh.MaxHealth) { return(true); } targetEntity = ent; return(false); }); return(targetEntity != null); }
public override bool ShouldExecute() { if (cooldownUntilMs > entity.World.ElapsedMilliseconds || failureTime > entity.World.ElapsedMilliseconds) { return(false); } prog = entity.GetBehavior <EntityBehaviorProgram>(); if (prog == null || prog.dormant || !prog.CheckArea() || prog.workStack == null) { return(false); } if (entity.LeftHandItemSlot.Itemstack != null) { return(false); } entityUtil.WalkEntities((prog.workArea.Start + prog.workArea.End) / 2, prog.workArea.Length + prog.workArea.Height + prog.workArea.Width, (ent) => { if (!prog.workArea.ContainsOrTouches(ent.ServerPos.XYZ) || ent.GetBehavior("milkable") == null && ent.GetBehavior("foodmilk") == null) { return(true); } ITreeAttribute mult = ent.WatchedAttributes.GetTreeAttribute("multiply"); if (ent.World.Calendar.TotalDays - mult.GetDouble("totalDaysLastBirth") <= 21 && ent.World.Calendar.TotalHours - ent.WatchedAttributes.GetFloat("lastMilkedTotalHours") >= ent.World.Calendar.HoursPerDay) { targetEntity = ent; return(false); } return(true); }); return(targetEntity != null); }
private void onPhysicsTickCallback(float dtFac) { if (ShouldDespawn || !Alive) { return; } if (World is IClientWorldAccessor || World.ElapsedMilliseconds <= msCollide + 500) { return; } if (ServerPos.Motion.X == 0 && ServerPos.Motion.Y == 0 && ServerPos.Motion.Z == 0) { return; //don't do damage if stuck in ground } Cuboidd projectileBox = CollisionBox.ToDouble().Translate(ServerPos.X, ServerPos.Y, ServerPos.Z); if (ServerPos.Motion.X < 0) { projectileBox.X1 += ServerPos.Motion.X * dtFac; } else { projectileBox.X2 += ServerPos.Motion.X * dtFac; } if (ServerPos.Motion.Y < 0) { projectileBox.Y1 += ServerPos.Motion.Y * dtFac; } else { projectileBox.Y2 += ServerPos.Motion.Y * dtFac; } if (ServerPos.Motion.Z < 0) { projectileBox.Z1 += ServerPos.Motion.Z * dtFac; } else { projectileBox.Z2 += ServerPos.Motion.Z * dtFac; } ep.WalkEntities(ServerPos.XYZ, 5f, (e) => { if (e.EntityId == this.EntityId || !e.IsInteractable) { return(false); } Cuboidd eBox = e.CollisionBox.ToDouble().Translate(e.ServerPos.X, e.ServerPos.Y, e.ServerPos.Z); if (eBox.IntersectsOrTouches(projectileBox)) { if (FiredBy != null && e.EntityId == FiredBy.EntityId && World.ElapsedMilliseconds - msLaunch < 500) { return(true); } impactOnEntity(e); return(false); } return(true); }); }