public void StartWorld() { //Logs.AddAppender(new ConsoleAppender()); //Logs.SetMessageLevel<ConsoleAppender>(LogMessageType.MSG_DEBUG); //Logs.AddAppender(new DebugAppender()); //Logs.SetMessageLevel<DebugAppender>(LogMessageType.MSG_DEBUG); w = new WorldBase(); w.StartWorld(); }
public static void TokenUseSkill(WorldBase world, int createrID, string skillID, Vector3 pos, Vector3 dir) { //Debug.Log("TokenUseSkill pos" + pos + " frame " + world.FrameCount + " skillID" + skillID); if (skillID != null && skillID != "null" && skillID != "Null") { SkillStatusComponent ssc = new SkillStatusComponent(); ssc.m_skillTime = 0; ssc.m_skillStstus = SkillStatusEnum.Before; ssc.m_isTriggerSkill = false; ssc.m_isHit = false; ssc.m_skillList.Add(new SkillData(skillID)); ssc.m_currentSkillData = ssc.GetSkillData(skillID); ssc.m_currentSkillData.UpdateInfo(); ssc.skillDir.FromVector(dir); if (ssc.m_currentSkillData.LaterTime == 0) { Debug.LogError("技能代 " + skillID + "的持续时间不能为 0 !"); return; } TransfromComponent tc = new TransfromComponent(); tc.pos.FromVector(pos); tc.dir.FromVector(dir); //打印 Debug.DrawRay(tc.pos.ToVector(), -tc.dir.ToVector(), Color.green, 10); CampComponent cc = new CampComponent(); cc.creater = createrID; LifeSpanComponent lsc = new LifeSpanComponent(); lsc.lifeTime = (int)(ssc.m_currentSkillData.LaterTime * 1000); world.CreateEntity(createrID + "SkillToken", tc, ssc, cc, lsc); } }
public override void OnCollidedWithBlock(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue) { base.OnCollidedWithBlock(_world, _clrIdx, _blockPos, _blockValue); //if (!this.hasDriver || player == null || lastLandHitToolTipTime != -1 && Time.time - 2f < lastLandHitToolTipTime) if (!this.hasDriver || lastLandHitToolTipTime != -1 && Time.time - 2f < lastLandHitToolTipTime) { return; } // Slowing down the boat when it touches the ground Block block = Block.list[_blockValue.type]; if (!hasWaterAbove() && !(block.GetBlockName() == "air") && !block.GetType().IsSubclassOf(typeof(BlockLiquid)) && !(block.GetType() == typeof(BlockLiquidv2)) && !(block.GetBlockName() == "smallBoatDummyBlock") && !(block.GetBlockName() == "waterSupportBlock")) { //DebugMsg("Boat is touching Ground!"); isTouchingGround = true; if (LZ_float_field != null) { LZ_float_field.SetValue(this.vehicle, 1f); if (this.player != null && Time.time - 5f > lastLandHitToolTipTime) { GameManager.ShowTooltip(this.player, "This Vehicle can only move on Water."); lastLandHitToolTipTime = Time.time; } } } else { // Back to normal speed when in water isTouchingGround = false; if (LZ_float_field != null) { LZ_float_field.SetValue(this.vehicle, maxSpeedBackup); lastLandHitToolTipTime = -1; } } }
/** * This is the activation text that displays when the player looks at this block. */ public override string GetActivationText(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing) { TileEntityBlockTransformer tileEntityBlockTransformer = _world.GetTileEntity(_clrIdx, _blockPos) as TileEntityBlockTransformer; if (tileEntityBlockTransformer == null) { return(string.Empty); } string arg = Localization.Get(Block.list[_blockValue.type].GetBlockName(), ""); PlayerActionsLocal playerInput = ((EntityPlayerLocal)_entityFocusing).playerInput; string keybindString = UIUtils.GetKeybindString(playerInput.Activate, playerInput.PermanentActions.Activate); if (!tileEntityBlockTransformer.bTouched) { return(string.Format(Localization.Get("lootTooltipNew", ""), keybindString, arg)); } if (tileEntityBlockTransformer.IsEmpty()) { return(string.Format(Localization.Get("lootTooltipEmpty", ""), keybindString, arg)); } return(string.Format(Localization.Get("lootTooltipTouched", ""), keybindString, arg)); }
private static void SetDensity(WorldBase world, Vector3i pos) { sbyte density = 1; if (Options.ContainsKey("d")) { if (sbyte.TryParse(Options["d"], out density)) { SendOutput($"Using density {density}"); } } var blockValue = world.GetBlock(pos); if (blockValue.Equals(BlockValue.Air)) { SendOutput($"Target block is air @ {pos}"); return; } if (blockValue.ischild) { SendOutput($"Target block is a child block @ {pos} - Parent@ {blockValue.parentx},{blockValue.parenty},{blockValue.parentz}"); return; } var d = world.GetDensity(0, pos); if (d == density) { SendOutput($"No change in density @ {pos}"); return; } world.SetBlockRPC(pos, blockValue, density); SendOutput($"Changing density on block from '{d}' to '{density}' @ {pos}"); }
public void selectKit(WorldBase world) { if (!locked) { SoundManager.getSound("click").playWithVariance(0, .25f, 0, SoundType.MONSTER); foreach (Item item in kit) { world.player.inventory.add(item.clone(item.uses)); } if (starterCards[0] != null) { ((Player)(world.player)).cards[0] = CardRegistrar.getCardFromIdPlayerAndLevel(CardRegistrar.getIDFromCard(starterCards[0]), starterCards[0].level, (Player)world.player); } if (starterCards[1] != null) { ((Player)(world.player)).cards[1] = CardRegistrar.getCardFromIdPlayerAndLevel(CardRegistrar.getIDFromCard(starterCards[1]), starterCards[1].level, (Player)world.player); } animations.apply(((Player)(world.player))); world.player.tutorialStringMovement = tutorialStringMovement; world.player.tutorialStringInventory = tutorialStringInventory; world.player.tutorialStringUseItems = tutorialStringUseItems; world.player.tutorialStringPostKeybinds = tutorialStringPostKeybinds; world.player.tutorialStringCrafting = tutorialStringCrafting; world.player.tutorialStringWeapon = tutorialStringWeapon; world.player.rebindAndFinish = rebindAndFinish; if (world is TutorialWorld) { ((TutorialWorld)world).processInstructionStrings(); } } }
public override void onUse(WorldBase world, Item harvestTool, Vector2 location, TileType tileType, Entity user) { base.onUse(world, harvestTool, location, tileType, user); Vector2 lampSpawnLoc = location + new Vector2(Chunk.tileDrawWidth / 2, -Chunk.tileDrawWidth); bool canSpawn = true; foreach (Entity entity in world.entities) { if (entity is EntityLamp && Vector2.Distance(lampSpawnLoc, entity.location) < Chunk.tileDrawWidth) { canSpawn = false; break; } } if (canSpawn) { world.addEntity(new EntityLamp(lampSpawnLoc, world)); } }
private static void SetPaint(WorldBase world, Vector3i pos) { byte texture = 0; if (Options.ContainsKey("t")) { if (!byte.TryParse(Options["t"], out texture)) { SendOutput("Unable to parse texture value"); return; } if (BlockTextureData.list[texture] == null) { SendOutput($"Unknown texture index {texture}"); return; } } var blockValue = world.GetBlock(pos); if (blockValue.Equals(BlockValue.Air)) { SendOutput($"Target block is air @ {pos}"); return; } if (blockValue.Block.shape.IsTerrain()) { SendOutput($"Target block is terrain @ {pos}"); return; } GameManager.Instance.SetBlockTextureServer(pos, BlockFace.None, texture, -1); SendOutput($"Painting block with texture '{BlockTextureData.GetDataByTextureID(texture)?.Name}' @ {pos}"); }
protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } if (world == null) { world = new WorldBase(0); } world.update(gameTime); Vector2 playerMoveDir = new Vector2(); if (Keyboard.GetState().IsKeyDown(Keys.A)) { playerMoveDir += new Vector2(-1, 0); } else if (Keyboard.GetState().IsKeyDown(Keys.D)) { playerMoveDir += new Vector2(1, 0); } if (Keyboard.GetState().IsKeyDown(Keys.W)) { playerMoveDir += new Vector2(0, -1); } else if (Keyboard.GetState().IsKeyDown(Keys.S)) { playerMoveDir += new Vector2(0, 1); } world.playerLoc += playerMoveDir * 5; base.Update(gameTime); }
/*public override Item clone(int uses) * { * return new Item_Berry(uses, alias, tags); * }*/ public override int use(PlayerBase user, WorldBase world, Vector2 location, GameTime time, BinaryInputManager inputManager) { base.use(user, world, location, time, inputManager); int used = 1; Console.WriteLine("Berry trace: " + tags[0] + ", " + tags[1]); if (tags[0] == POISONED || tags[1] == POISONED) { user.hunger -= 10; user.health -= 5; } if (tags[0] == SPEEDY || tags[1] == SPEEDY) { user.addStatusEffect(new StatusEffect(StatusEffect.status.SPEED, .7f, 150, false)); } if (tags[0] == LEAPING || tags[1] == LEAPING) { user.addStatusEffect(new StatusEffect(StatusEffect.status.JUMP, .6f, 150, false)); } if (tags[0] == REGEN || tags[1] == REGEN) { user.addStatusEffect(new StatusEffect(StatusEffect.status.HEALTHREGEN, 20, 150, false)); } if (tags[0] == FILLING || tags[1] == FILLING) { user.hunger += 10; } else if (tags[0] == NONE || tags[1] == NONE) { user.hunger += 5; } SoundManager.getSound("eat").playWithVariance(0, .2f, 0, .5f, .5f, 0, SoundType.MONSTER); return(used); }
static void ReceviceSameCmdMsg(SyncSession session, SameCommand msg) { //消息确认 AffirmMsg amsg = new AffirmMsg(); amsg.index = msg.frame; amsg.time = msg.time; ProtocolAnalysisService.SendMsg(session, amsg); ConnectionComponent connectComp = session.m_connect; if (connectComp != null) { WorldBase world = connectComp.Entity.World; //取上一帧的数据 T scmd = (T)connectComp.GetCommand(msg.frame - 1).DeepCopy(); //msg.frame = world.FrameCount + 1; scmd.frame = world.FrameCount + 1; if (connectComp.AddCommand(scmd)) { //BroadcastSameCommand(world, connectComp, msg, true); } //} //else //{ // //Debug.Log("Same frame " + world.FrameCount); // //scmd.frame = world.FrameCount + 1; // //connectComp.AddCommand(scmd); //} ControlSpeed(connectComp, world, msg.frame); } }
public override int use(PlayerBase user, WorldBase world, Vector2 location, GameTime time, BinaryInputManager inputManager) { base.use(user, world, location, time, inputManager); int used = 1; Console.WriteLine("Bottle trace: " + tags[0] + ", " + tags[1]); if (tags[0] == Item_Berry.POISONED || tags[1] == Item_Berry.POISONED) { user.hunger -= 20; user.health -= 10; } if (tags[0] == Item_Berry.SPEEDY || tags[1] == Item_Berry.SPEEDY) { user.addStatusEffect(new StatusEffect(StatusEffect.status.SPEED, 1.2f, 350, false)); } if (tags[0] == Item_Berry.LEAPING || tags[1] == Item_Berry.LEAPING) { user.addStatusEffect(new StatusEffect(StatusEffect.status.JUMP, .8f, 350, false)); } if (tags[0] == Item_Berry.REGEN || tags[1] == Item_Berry.REGEN) { user.addStatusEffect(new StatusEffect(StatusEffect.status.HEALTHREGEN, 40, 550, false)); } if (tags[0] == Item_Berry.FILLING || tags[1] == Item_Berry.FILLING) { user.hunger += 10; } else if (tags[0] == Item_Berry.NONE || tags[1] == Item_Berry.NONE) { user.hunger += 10; } SoundManager.getSound("drink").playWithVariance(0, .2f, 0, SoundType.MONSTER); return(used); }
public static bool Prefix(Block __instance, WorldBase world, int _clrIdx, Vector3i _myBlockPos, BlockValue _myBlockValue, Vector3i _blockPosThatChanged, BlockValue _newNeighborBlockValue, BlockValue _oldNeighborBlockValue) { if (!Configuration.CheckFeatureStatus(AdvFeatureClass, Feature)) { return(true); } // skip this check if its terrain if (_myBlockValue.Block.shape.IsTerrain()) { return(true); } // if the block that's changed is an air block, and it's below the block, crumble it, since we don't want it floating. if (_newNeighborBlockValue.Block.GetBlockName() == "caveBlock02" && _blockPosThatChanged == _myBlockPos + Vector3i.down) { var block = world.GetBlock(_myBlockPos); block.Block.DamageBlock(world, _clrIdx, _myBlockPos, _myBlockValue, block.Block.MaxDamage, -1); return(false); } return(true); }
public override int use(PlayerBase user, WorldBase world, Vector2 location, GameTime time, BinaryInputManager inputManager) { base.use(user, world, location, time, inputManager); int used = 0; Item_Bullet item_bullet = (Item_Bullet)user.inventory.getItemOfType(new Item_Bullet(1)); if (item_bullet != null) { user.inventory.consume(item_bullet, 1); EntityLaserBolt laserBolt = new EntityLaserBolt(user.location + new Vector2(0, -15), world, user); laserBolt.velocity += Vector2.Normalize(location - user.location) * 30; world.addEntity(laserBolt); used = 1; SoundManager.getSound("gun-fire").playWithVariance(0, 1, 0, SoundType.MONSTER); } return(used); }
private static void UpgradeBlock(WorldBase world, Vector3i pos) { var blockValue = world.GetBlock(pos); var upgradeBlockValue = blockValue.Block.UpgradeBlock; if (upgradeBlockValue.Equals(BlockValue.Air)) { SendOutput($"Target block has no upgrade @ {pos}"); return; } if (blockValue.ischild) { SendOutput($"Can't upgrade a child block @ {pos} - Parent@ {blockValue.parentx},{blockValue.parenty},{blockValue.parentz}"); return; } upgradeBlockValue.rotation = blockValue.rotation; world.SetBlockRPC(pos, upgradeBlockValue); SendOutput($"Upgrading block from '{blockValue.Block.GetBlockName()}' to '{upgradeBlockValue.Block.GetBlockName()}' @ {pos}"); }
public override bool OnBlockActivated(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, EntityAlive _player) { BlockEntityData _ebcd = _world.ChunkClusters[_clrIdx].GetBlockEntity(_blockPos); if (!BlockCCTVScreen.Screen0(_blockValue.meta) && !BlockCCTVScreen.Screen1(_blockValue.meta) && !BlockCCTVScreen.Screen2(_blockValue.meta) && !BlockCCTVScreen.Screen3(_blockValue.meta)) { return(false); } else { screen0Mesh.enabled = false; screen1Mesh.enabled = false; screen2Mesh.enabled = false; screen3Mesh.enabled = false; _blockValue.meta = (byte)(_blockValue.meta & ~(1 << 0)); _blockValue.meta = (byte)(_blockValue.meta & ~(1 << 1)); _blockValue.meta = (byte)(_blockValue.meta & ~(1 << 2)); _blockValue.meta = (byte)(_blockValue.meta & ~(1 << 3)); _world.SetBlockRPC(_blockPos, _blockValue); ForceScreens(_blockPos, _blockValue, _ebcd); return(false); } }
public override bool OnBlockActivated(WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityAlive _player) { if (!Stopped(_blockValue.meta2) || WasLooted(_blockValue.meta2)) { return(false); } var lootable = false; if (Properties.Values.ContainsKey(PropLootable) && !bool.TryParse(Properties.Values[PropLootable], out lootable)) { Debug.Log("Unable to parse " + PropLootable + " as a bool in " + _blockValue.Block.GetBlockName()); } if (!lootable) { return(false); } _blockValue.meta2 = (byte)(_blockValue.meta2 | (1 << 2)); _world.SetBlockRPC(_cIdx, _blockPos, _blockValue); return(base.OnBlockActivated(_world, _cIdx, _blockPos, _blockValue, _player)); }
public override int use(PlayerBase user, WorldBase world, Vector2 location, GameTime time, BinaryInputManager inputManager) { base.use(user, world, location, time, inputManager); /*EntityMacuhatilSlash macuhatilSlash = new EntityMacuhatilSlash(user.location + new Vector2(0, 20), world, user); * macuhatilSlash.velocity += Vector2.Normalize(location - user.location) * .1f; * world.addEntity(macuhatilSlash);*/ if (user is Player) { Player player = (Player)user; if (player.state.actionPermitted(STATE_ACTIONS.SWING)) { int dir = -1; if (player.facing > 0) { dir = 1; } EntityMacuhatilSlash macuhatilSlash = new EntityMacuhatilSlash(user.location + new Vector2(dir * 35, 20), world, user); macuhatilSlash.velocity += Vector2.Normalize(location - user.location) * .1f; player.state.decorate(macuhatilSlash); world.addEntity(macuhatilSlash); player.state.submitStateAction(STATE_ACTIONS.SWING); SoundManager.getSound("sword-slash").playWithVariance(-.5f, .2f, 0, SoundType.MONSTER); } } else { EntityMacuhatilSlash macuhatilSlash = new EntityMacuhatilSlash(user.location + new Vector2(0, 20), world, user); macuhatilSlash.velocity += Vector2.Normalize(location - user.location) * .1f; world.addEntity(macuhatilSlash); SoundManager.getSound("sword-slash").playWithVariance(-.5f, .2f, 0, SoundType.MONSTER); } return(0); }
private void OnGUI() { GUILayout.Space(5); if (GUILayout.Button("刷新")) { OnEnable(); } GUILayout.Space(5); selectStr = EditorDrawGUIUtil.DrawPopup("选择世界:", selectStr, worldNames); if (worldList == null || worldList.Count == 0 || string.IsNullOrEmpty(selectStr)) { GUILayout.Label("无数据"); return; } selectWorld = worldDic[selectStr]; GUILayout.Space(5); toolbarOption = GUILayout.Toolbar(toolbarOption, toolbarTexts); switch (toolbarOption) { case 0: ShowEntitysGUI(selectWorld); break; case 1: ShowSingleComponentGUI(selectWorld); break; case 2: ShowGroupsGUI(selectWorld); break; } }
public static CollisionHull CreateHeightFieldCollision(WorldBase world, int shapeID, short[,] heights, byte[,] materialIDs, bool gridsDiagonals_TopleftToBottomright, double horizontalScale, double verticalScale) { //NOTE: Height field doesn't look at the body's mass, it is static (terrain). Other stuff bounces off of this // I believe materialIDs is the material ID for each grid point, so the terrain can have different elasticities/friction //TODO: Make a helper method that builds a height field out of a bitmap (or 2 bitmaps, one for the heights, one for the materials) // Turn the 2D array into a 1D array int width = heights.GetUpperBound(0); int height = heights.GetUpperBound(1); if (materialIDs.GetUpperBound(0) != width || materialIDs.GetUpperBound(1) != height) { throw new ArgumentException(string.Format("The height array is a different size than the materialID array (height={0}x{1}, material={2}x{3}", width.ToString(), height.ToString(), materialIDs.GetUpperBound(0).ToString(), materialIDs.GetUpperBound(1).ToString())); } short[] heights1D = new short[width * height]; byte[] materials1D = new byte[heights1D.Length]; for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { heights1D[(width * x) + y] = heights[x, y]; materials1D[(width * x) + y] = materialIDs[x, y]; } } // Convert bool to int int gridsDiagonals = gridsDiagonals_TopleftToBottomright ? 1 : 0; // false is bottom left to top right // Create in newton IntPtr handle = Newton.NewtonCreateHeightFieldCollision(world.Handle, width, height, gridsDiagonals, heights1D, materials1D, Convert.ToSingle(horizontalScale), Convert.ToSingle(verticalScale), shapeID); // Exit Function return(new CollisionHull(handle, world, null, CollisionShapeType.HeightField)); }
// Display custom messages for turning on and off the music box, based on the block's name. public override string GetActivationText(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing) { #region GetActivationText PlayerActionsLocal playerInput = ((EntityPlayerLocal)_entityFocusing).playerInput; string keybindString = playerInput.Activate.GetBindingXuiMarkupString(XUiUtils.EmptyBindingStyle.EmptyString, XUiUtils.DisplayStyle.Plain) + playerInput.PermanentActions.Activate.GetBindingXuiMarkupString(XUiUtils.EmptyBindingStyle.EmptyString, XUiUtils.DisplayStyle.Plain); //string keybindString = UIUtils.GetKeybindString(playerInput.Activate, playerInput.PermanentActions.Activate); Block block = Block.list[_blockValue.type]; string blockName = block.GetBlockName(); string strReturn = string.Format(Localization.Get("pickupPrompt"), Localization.Get(blockName)); BlockEntityData _ebcd = _world.GetChunkFromWorldPos(_blockPos).GetBlockEntity(_blockPos); if (_ebcd != null && _ebcd.transform) { MusicBoxScript myMusicBoxScript = _ebcd.transform.GetComponent <MusicBoxScript>(); if (myMusicBoxScript == null) { myMusicBoxScript = _ebcd.transform.gameObject.AddComponent <MusicBoxScript>(); myMusicBoxScript.enabled = false; } if (myMusicBoxScript) { if (myMusicBoxScript.enabled) { strReturn = string.Format(Localization.Get("musicbox_turnOff") + this.GetBlockName(), keybindString); } else { strReturn = string.Format(Localization.Get("musicbox_turnOn") + this.GetBlockName(), keybindString); } } } return(strReturn); #endregion }
public override void OnBlockEntityTransformBeforeActivated(WorldBase _world, Vector3i _blockPos, int _cIdx, BlockValue _blockValue, BlockEntityData _ebcd) { this.shape.OnBlockEntityTransformBeforeActivated(_world, _blockPos, _cIdx, _blockValue, _ebcd); DebugMsg("OnBlockEntityTransformBeforeActivated"); try { if (_ebcd != null && _ebcd.bHasTransform) { GameObject gameObject = _ebcd.transform.gameObject; PerpetualMotionGeneratorControl PMGControlScript = gameObject.GetComponent <PerpetualMotionGeneratorControl>(); if (PMGControlScript == null) { PMGControlScript = gameObject.AddComponent <PerpetualMotionGeneratorControl>(); } PMGControlScript.enabled = true; PMGControlScript.cIdx = _cIdx; PMGControlScript.blockPos = _blockPos; PMGControlScript.soundRepeat = soundRepeat; } else { DebugMsg("ERROR: _ebcd null (OnBlockEntityTransformBeforeActivated)"); } } catch (Exception ex) { DebugMsg("Error Message: " + ex.ToString()); } // Offset wire so that it's at the base of the Healing Pod TileEntityPowerSource tileEntityPowerSource = (TileEntityPowerSource)_world.GetTileEntity(_cIdx, _blockPos); if (tileEntityPowerSource != null) { tileEntityPowerSource.WireOffset = new Vector3(0.25f, 0.4f, 0); } }
public override void OnBlockEntityTransformBeforeActivated(WorldBase _world, Vector3i _blockPos, int _cIdx, BlockValue _blockValue, BlockEntityData _ebcd) { this.shape.OnBlockEntityTransformBeforeActivated(_world, _blockPos, _cIdx, _blockValue, _ebcd); DebugMsg("OnBlockEntityTransformBeforeActivated"); try { if (_ebcd != null && _ebcd.bHasTransform) { GameObject gameObject = _ebcd.transform.gameObject; HealingPodControl healingPodControlScript = gameObject.GetComponent <HealingPodControl>(); if (healingPodControlScript == null) { healingPodControlScript = gameObject.AddComponent <HealingPodControl>(); } healingPodControlScript.enabled = true; healingPodControlScript.cIdx = _cIdx; healingPodControlScript.blockPos = _blockPos; } else { DebugMsg("ERROR: _ebcd null (OnBlockEntityTransformBeforeActivated)"); } } catch (Exception ex) { DebugMsg("Error Message: " + ex.ToString()); } // Offset wire so that it's at the base of the Healing Pod TileEntityPowered tileEntityPowered = (TileEntityPowered)_world.GetTileEntity(_cIdx, _blockPos); if (tileEntityPowered != null) { tileEntityPowered.WireOffset = new Vector3(0, -0.5f, 0); } }
public static bool Prefix(Block __instance, WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue) { if (!Configuration.CheckFeatureStatus(AdvFeatureClass, Feature)) { return(true); } if (!__instance.isMultiBlock) { int type = _world.GetBlock(_clrIdx, _blockPos).type; return((type != 0 || Block.list[type].GetBlockName() == "caveBlock02") && !Block.list[type].blockMaterial.IsGroundCover && !Block.list[type].blockMaterial.IsLiquid); } byte rotation = _blockValue.rotation; for (int i = __instance.multiBlockPos.Length - 1; i >= 0; i--) { int type2 = _world.GetBlock(_clrIdx, _blockPos + __instance.multiBlockPos.Get(i, _blockValue.type, (int)rotation)).type; if (type2 != 0 && !Block.list[type2].blockMaterial.IsGroundCover && !Block.list[type2].blockMaterial.IsLiquid) { return(true); } } return(false); }
/** * This is called when block is removed. We want to destroy existing tile entity too. */ public override void OnBlockRemoved(WorldBase _world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue) { if (!_blockValue.ischild) { this.shape.OnBlockRemoved(_world, _chunk, _blockPos, _blockValue); if (this.isMultiBlock) { this.multiBlockPos.RemoveChilds(_world, _chunk.ClrIdx, _blockPos, _blockValue); return; } } else if (this.isMultiBlock) { this.multiBlockPos.RemoveParentBlock(_world, _chunk.ClrIdx, _blockPos, _blockValue); } TileEntityBlockTransformer tileEntityBlockTransformer = _world.GetTileEntity(_chunk.ClrIdx, _blockPos) as TileEntityBlockTransformer; if (tileEntityBlockTransformer != null) { tileEntityBlockTransformer.OnDestroy(); } this.removeTileEntity(_world, _chunk, _blockPos, _blockValue); }
public void OnNeighborBlockChange(WorldBase world, int _clrIdx, Vector3i _myBlockPos, BlockValue _myBlockValue, Vector3i _blockPosThatChanged, BlockValue _newNeighborBlockValue, BlockValue _oldNeighborBlockValue) { // If I was inserting a new BV wo rotation, the slime would stick below ? if (!this.onb) { return; } Printer.Log(71, "OnNeighborBlockChange", _myBlockPos, _blockPosThatChanged, this.GetHashCode(), "damage", _myBlockValue.damage); if (_myBlockPos.y != _blockPosThatChanged.y + 1) { return; // only react to below block } if (!IsEmpty(_newNeighborBlockValue.Block)) { return; // only when below is empty } int felt = TryFall(_myBlockPos, _myBlockValue); if (dt > 0 && felt <= gravity) { world.GetWBT().AddScheduledBlockUpdate(0, _myBlockPos - felt * Vectors.UnitY, Block.blockID, dt); } }
// custom function to operate the trap. If it is resulting from a collision "fireTrap" will be true, if its player interaction it will be false. private void OperateTrap(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, Entity _entity, bool fireTrap) { // here's where we do operation actions. This will only run if the originator is alive! if (!_entity.IsAlive()) { return; } if (fireTrap) { // if the operation results from block collision, we will try to "open" the trap. // but only if it's not already opened (waiting for reset) if (!BlockTrapTutorial.IsTrapFired(_blockValue.meta)) { #region Fire trap; // I will be using the bit 0, and set it to 1 here. This will let everyone know that the trap is open (waiting for reset) _blockValue.meta = (byte)(_blockValue.meta | (1 << 0)); // as soon as we "commit" this information, all clients will be informed and the correct animations will play _world.SetBlockRPC(_clrIdx, _blockPos, _blockValue); #endregion ; } } else { // if the operation results from player interaction (reseting the trap) if (BlockTrapTutorial.IsTrapFired(_blockValue.meta)) { #region Reset trap; // I will be using the bit 0, and reset it to 0. This will let everyone know that the trap is ready and will fire if collided. _blockValue.meta = (byte)(_blockValue.meta & ~(1 << 0)); // as soon as we "commit" this information, all clients will be informed and the correct animations will play _world.SetBlockRPC(_clrIdx, _blockPos, _blockValue); #endregion ; } } }
static void ReceviceSyncMsg(SyncSession session, T msg) { ConnectionComponent commandComp = session.m_connect; WorldBase world = session.m_entity.World; if (commandComp != null) { PlayerCommandBase comp = msg; comp.frame = msg.frame; if (msg.frame > world.FrameCount) { commandComp.m_commandList.Add(comp); //TODO 广播操作 } else { //TODO 潜在的不同步威胁 Debug.Log("帧数落后 丢弃玩家操作 world.FrameCount: " + world.FrameCount + " msg frame:" + msg.frame); commandComp.m_lastInputCache = comp; } } }
public override void OnBlockEntityTransformAfterActivated(WorldBase _world, Vector3i _blockPos, int _cIdx, BlockValue _blockValue, BlockEntityData _ebcd) { base.OnBlockEntityTransformAfterActivated(_world, _blockPos, _cIdx, _blockValue, _ebcd); SetTag(_ebcd.transform, _ebcd.transform, "T_Block"); //this is a really ugly way of doing it but there's no update tick on clients for dedi support if (Network.isClient) { Block block = Block.list.FirstOrDefault(d => d != null && d.GetBlockName() == "Windmill"); //.list[BlockID]; if (block == null) { Debug.Log("Can't find windmill block"); return; } var MinSpeed = 0f; var MaxSpeed = 0f; var WattPerMph = 0f; if (block.Properties.Values.ContainsKey("MinWindSpeed")) { MinSpeed = float.Parse(block.Properties.Values["MinWindSpeed"]); } if (block.Properties.Values.ContainsKey("MaxWindSpeed")) { MaxSpeed = float.Parse(block.Properties.Values["MaxWindSpeed"]); } if (block.Properties.Values.ContainsKey("WattPerMph")) { WattPerMph = float.Parse(block.Properties.Values["WattPerMph"]); } var animator = _ebcd.transform.gameObject.GetComponent <Animator>(); GameManager.Instance.StartCoroutine(CheckAnimation(animator, _cIdx, _blockPos, MinSpeed, MaxSpeed, WattPerMph)); } }
public WormHead(Vector2 location, WorldBase world) : base(location, world) { location = location + new Vector2(0, 200);//The worm isn't interesting unless buried in the earth width = 40; height = 40; walkSpeed = .5f; wasPlayerCollidingBottomLastRound = false; latchLoc = resting; int bodySegmentSpacing = (int)(width * .9f); int numSegments = 8 + rand.Next(8); health += numSegments * 10; Entity last = this; for (int i = 0; i < numSegments; i++) { WormBodySegment bodySegment = new WormBodySegment(location + new Vector2(i * bodySegmentSpacing, 0), world, last); last = bodySegment; world.addEntity(bodySegment); } currentTex = Game1.texture_worm_head[0]; windMultiplier = 0; }
/// <summary> /// 有实例产生时调用 /// </summary> /// <param name="clientSocket"></param> /// <param name="messagePump"></param> internal NetState(ClientSocketManager clientSocket, MessagePump messagePump) { if (clientSocket == null) throw new ArgumentNullException("clientSocket", "NetState.NetState(...) - clientSocket == null error!"); if (messagePump == null) throw new ArgumentNullException("messagePump", "NetState.NetState(...) - messagePump == null error!"); if (messagePump.World == null) throw new ArgumentNullException("messagePump.World", "NetState.NetState(...) - messagePump.World == null error!"); m_Socket = clientSocket; m_MessagePump = messagePump; m_ConnectedOn = OneServer.NowTime; m_World = messagePump.World; m_ToString = clientSocket.Address; m_NextCheckActivity = m_ConnectedOn + m_World.CheckAliveTime; IPAddress ipAddress = null; IPAddress.TryParse(clientSocket.RemoteOnlyIP, out ipAddress); if (ipAddress == null) m_NetAddress = new IPEndPoint(IPAddress.None, clientSocket.RemotePort); else m_NetAddress = new IPEndPoint(ipAddress, clientSocket.RemotePort); }
/// <summary> /// 有实例产生时调用 /// </summary> /// <param name="clientSocket"></param> /// <param name="world"></param> public NetState(ClientSession<NetState> clientSocket, WorldBase world) : this() { if (clientSocket == null) throw new ArgumentNullException("clientSocket", "NetState.NetState(...) - clientSocket == null error!"); m_Socket = clientSocket; IPAddress ipAddress; IPAddress.TryParse(clientSocket.RemoteOnlyIP, out ipAddress); if (ipAddress == null) m_NetAddress = new IPEndPoint(IPAddress.None, clientSocket.RemotePort); else m_NetAddress = new IPEndPoint(ipAddress, clientSocket.RemotePort); World = world; ReceiveBuffer = new ReceiveQueue(); }
/// <summary> /// 退出World集合,在BaseWorld中调用 /// </summary> internal void ExitWorld() { // 置空 m_Serial = Serial.MinusOne; m_Running = false; m_Socket.Data = null; Player = null; World = null; }
public override CollisionHull CreateCollisionHull(WorldBase world) { return(SensorGravityDesign.CreateSensorCollisionHull(world, this.Scale, this.Orientation, this.Position)); }
/// <summary> /// 无效实例产生时调用 /// </summary> /// <param name="clientSocket"></param> /// <param name="messagePump"></param> public NetState() { m_Socket = null; m_MessagePump = null; m_ConnectedOn = OneServer.NowTime; m_World = null; m_ToString = "0.0.0.0"; m_NextCheckActivity = DateTime.MaxValue; m_NetAddress = new IPEndPoint(IPAddress.None, 0); m_Disposed.SetInvalid(); }