public override bool SharedOnDamage( WeaponFinalCache weaponCache, IStaticWorldObject targetObject, double damagePreMultiplier, out double obstacleBlockDamageCoef, out double damageApplied) { if (weaponCache.ProtoExplosive is not null) { // allow to explode only a resource deposit which could be claimed if (WorldMapResourceMarksSystem.SharedCalculateTimeRemainsToClaimCooldownSeconds(targetObject) <= 0) { // accept explosive damage return(base.SharedOnDamage(weaponCache, targetObject, damagePreMultiplier, out obstacleBlockDamageCoef, out damageApplied)); } using var tempScopedBy = Api.Shared.GetTempList <ICharacter>(); Server.World.GetScopedByPlayers(targetObject, tempScopedBy); this.CallClient(tempScopedBy.AsList(), _ => _.ClientRemote_NoDamageToDepositUnderClaimDelay(weaponCache.ProtoExplosive)); } // only damage from explosives is accepted obstacleBlockDamageCoef = 0; damageApplied = 0; // no damage return(false); // no hit }
private int CalculateTimeToClaim() { if (this.worldObjectDeposit is null) { return(0); } var mark = WorldMapResourceMarksSystem.SharedEnumerateMarks() .FirstOrDefault(m => m.Id == this.worldObjectDeposit.Id); return((int)WorldMapResourceMarksSystem.SharedCalculateTimeToClaimLimitRemovalSeconds(mark.ServerSpawnTime)); }
protected override void ServerInitialize(ServerInitializeData data) { base.ServerInitialize(data); var privateState = data.PrivateState; if (data.IsFirstTimeInit) { privateState.ServerSpawnTime = Server.Game.FrameTime; } WorldMapResourceMarksSystem.ServerAddMark(data.GameObject, privateState.ServerSpawnTime); }
protected override void ServerInitialize(ServerInitializeData data) { base.ServerInitialize(data); var privateState = data.PrivateState; if (data.IsFirstTimeInit) { privateState.ServerSpawnTime = this.LifetimeTotalDurationSeconds > 0 ? Server.Game.FrameTime : 0; } WorldMapResourceMarksSystem.ServerAddMark(data.GameObject, privateState.ServerSpawnTime); }
private int CalculateTimeToClaim() { if (this.worldObjectDeposit == null) { return(0); } var position = WorldMapResourceMarksSystem.SharedGetObjectCenterPosition(this.worldObjectDeposit); var mark = WorldMapResourceMarksSystem.SharedEnumerateMarks() .FirstOrDefault(m => m.Position == position && m.ProtoWorldObject == this.protoDeposit); if (mark.Position == default) { return(0); } return((int)WorldMapResourceMarksSystem.SharedCalculateTimeToClaimLimitRemovalSeconds( mark.ServerSpawnTime)); }
protected virtual int ServerDecayIntervalSeconds => 60; // every minute public override void ServerOnDestroy(IStaticWorldObject gameObject) { base.ServerOnDestroy(gameObject); WorldMapResourceMarksSystem.ServerRemoveMark(gameObject); }
protected override void ServerInitialize(ServerInitializeData data) { base.ServerInitialize(data); WorldMapResourceMarksSystem.ServerAddMark(data.GameObject); }