public static ThrowingEntity CreateThrowingEntity( ThrowingContext throwingContext, IEntityIdGenerator entityIdGenerator, PlayerEntity playerEntity, int serverTime, Vector3 dir, float initVel, NewWeaponConfigItem newWeaponConfig, ThrowingConfig throwingConfig) { int throwingEntityId = entityIdGenerator.GetNextEntityId(); var emitPost = PlayerEntityUtility.GetThrowingEmitPosition(playerEntity); Vector3 velocity = dir * initVel; var throwingEntity = throwingContext.CreateEntity(); throwingEntity.AddEntityKey(new EntityKey(throwingEntityId, (int)EEntityType.Throwing)); throwingEntity.AddThrowingData( velocity, false, false, 0, serverTime, false, initVel, throwingConfig, newWeaponConfig.SubType ); throwingEntity.AddPosition(emitPost); throwingEntity.AddOwnerId(playerEntity.entityKey.Value); throwingEntity.isFlagSyncNonSelf = true; throwingEntity.AddLifeTime(DateTime.Now, throwingConfig.CountdownTime + 2000); return(throwingEntity); }
public static ThrowingEntity CreateThrowingEntity(PlayerWeaponController controller, int serverTime, Vector3 dir, Vector3 viePos, float initVel, WeaponResConfigItem newWeaponConfig, ThrowingConfig throwingConfig) { int throwingEntityId = EntityIdGenerator.GetNextEntityId(); Vector3 velocity = dir * initVel; ThrowingEntity throwingEntity = ThrowingContext.CreateEntity(); throwingEntity.AddEntityKey(new EntityKey(throwingEntityId, (int)EEntityType.Throwing)); // throwingEntity.AddThrowingData(velocity, false, false, 0, serverTime, false, initVel, throwingConfig, // newWeaponConfig.SubType); throwingEntity.AddThrowingData(throwingConfig, newWeaponConfig, initVel, 0, serverTime, velocity, newWeaponConfig.SubType); throwingEntity.AddPosition(); //TODO:EmitPos,ViewPos做射线检测取合适的点 throwingEntity.position.Value = viePos; throwingEntity.AddOwnerId(controller.Owner); throwingEntity.isFlagSyncNonSelf = true; throwingEntity.AddLifeTime(DateTime.Now, throwingConfig.CountdownTime + 2000); _logger.InfoFormat("CreateThrowing from {0} with velocity {1}, entity key {2}", throwingEntity.position.Value, throwingEntity.throwingData.Velocity, throwingEntity.entityKey); return(throwingEntity); }