mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 12:05:51 -04:00
Praise be to our robot overloads. Start refactoring bot instructions to be more extensible.
This commit is contained in:
parent
c25602b429
commit
f2eef89460
23
Bots/Instructions/BasicInstructions.cs
Normal file
23
Bots/Instructions/BasicInstructions.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2010 MCSharp team (Modified for use with MCZall/MCLawl/MCGalaxy)
|
||||||
|
|
||||||
|
Dual-licensed under the Educational Community License, Version 2.0 and
|
||||||
|
the GNU General Public License, Version 3 (the "Licenses"); you may
|
||||||
|
not use this file except in compliance with the Licenses. You may
|
||||||
|
obtain a copy of the Licenses at
|
||||||
|
|
||||||
|
http://www.opensource.org/licenses/ecl2.php
|
||||||
|
http://www.gnu.org/licenses/gpl-3.0.html
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the Licenses are distributed on an "AS IS"
|
||||||
|
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
|
or implied. See the Licenses for the specific language governing
|
||||||
|
permissions and limitations under the Licenses.
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace MCGalaxy.Bots {
|
||||||
|
}
|
23
Bots/Instructions/ComplexInstructions.cs
Normal file
23
Bots/Instructions/ComplexInstructions.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2010 MCSharp team (Modified for use with MCZall/MCLawl/MCGalaxy)
|
||||||
|
|
||||||
|
Dual-licensed under the Educational Community License, Version 2.0 and
|
||||||
|
the GNU General Public License, Version 3 (the "Licenses"); you may
|
||||||
|
not use this file except in compliance with the Licenses. You may
|
||||||
|
obtain a copy of the Licenses at
|
||||||
|
|
||||||
|
http://www.opensource.org/licenses/ecl2.php
|
||||||
|
http://www.gnu.org/licenses/gpl-3.0.html
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the Licenses are distributed on an "AS IS"
|
||||||
|
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
|
or implied. See the Licenses for the specific language governing
|
||||||
|
permissions and limitations under the Licenses.
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace MCGalaxy.Bots {
|
||||||
|
}
|
45
Bots/Instructions/Instruction.cs
Normal file
45
Bots/Instructions/Instruction.cs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2010 MCSharp team (Modified for use with MCZall/MCLawl/MCGalaxy)
|
||||||
|
|
||||||
|
Dual-licensed under the Educational Community License, Version 2.0 and
|
||||||
|
the GNU General Public License, Version 3 (the "Licenses"); you may
|
||||||
|
not use this file except in compliance with the Licenses. You may
|
||||||
|
obtain a copy of the Licenses at
|
||||||
|
|
||||||
|
http://www.opensource.org/licenses/ecl2.php
|
||||||
|
http://www.gnu.org/licenses/gpl-3.0.html
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the Licenses are distributed on an "AS IS"
|
||||||
|
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
|
or implied. See the Licenses for the specific language governing
|
||||||
|
permissions and limitations under the Licenses.
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace MCGalaxy.Bots {
|
||||||
|
|
||||||
|
/// <summary> Represents an action that a bot will perform </summary>
|
||||||
|
public abstract class Instruction {
|
||||||
|
|
||||||
|
/// <summary> Gets the identifying name for this instruction. </summary>
|
||||||
|
public abstract string Name { get; }
|
||||||
|
|
||||||
|
/// <summary> Performs a step for this instruction. </summary>
|
||||||
|
/// <returns> true if the instruction has finished, and that the
|
||||||
|
/// bot should proceed to execute the next instruction. </returns>
|
||||||
|
public abstract bool Execute(PlayerBot bot, InstructionData data);
|
||||||
|
|
||||||
|
/// <summary> Parses the given line which contains the metadata for this instruction. </summary>
|
||||||
|
public abstract InstructionData Parse(string[] args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct InstructionData {
|
||||||
|
public string type, newscript;
|
||||||
|
public int seconds, rotspeed;
|
||||||
|
public ushort x, y, z;
|
||||||
|
public byte rotx, roty;
|
||||||
|
}
|
||||||
|
}
|
@ -41,9 +41,8 @@ namespace MCGalaxy {
|
|||||||
public int cur = 0;
|
public int cur = 0;
|
||||||
public int countdown = 0;
|
public int countdown = 0;
|
||||||
public bool nodUp = false;
|
public bool nodUp = false;
|
||||||
public List<Pos> Waypoints = new List<Pos>();
|
public List<InstructionData> Waypoints = new List<InstructionData>();
|
||||||
public struct Pos { public string type, newscript; public int seconds, rotspeed; public ushort x, y, z; public byte rotx, roty; }
|
|
||||||
|
|
||||||
public ushort[] pos = new ushort[3], oldpos = new ushort[3], foundPos = new ushort[3];
|
public ushort[] pos = new ushort[3], oldpos = new ushort[3], foundPos = new ushort[3];
|
||||||
public byte[] rot = new byte[2], oldrot = new byte[2];
|
public byte[] rot = new byte[2], oldrot = new byte[2];
|
||||||
public bool movement = false;
|
public bool movement = false;
|
||||||
|
@ -27,7 +27,7 @@ namespace MCGalaxy.Bots {
|
|||||||
string[] codes = File.ReadAllLines(file);
|
string[] codes = File.ReadAllLines(file);
|
||||||
if (codes[0] != "#Version 2") { Player.Message(p, "Invalid file version. Remake"); return false; }
|
if (codes[0] != "#Version 2") { Player.Message(p, "Invalid file version. Remake"); return false; }
|
||||||
|
|
||||||
PlayerBot.Pos newPos = new PlayerBot.Pos();
|
PlayerBot.InstructionData newPos = new PlayerBot.InstructionData();
|
||||||
try { bot.Waypoints.Clear(); } catch { }
|
try { bot.Waypoints.Clear(); } catch { }
|
||||||
bot.cur = 0; bot.countdown = 0; bot.movementSpeed = 3;
|
bot.cur = 0; bot.countdown = 0; bot.movementSpeed = 3;
|
||||||
|
|
||||||
|
@ -112,6 +112,9 @@
|
|||||||
<Compile Include="Blocks\BlockProperties.cs" />
|
<Compile Include="Blocks\BlockProperties.cs" />
|
||||||
<Compile Include="Bots\BotsFile.cs" />
|
<Compile Include="Bots\BotsFile.cs" />
|
||||||
<Compile Include="Bots\Instructions.cs" />
|
<Compile Include="Bots\Instructions.cs" />
|
||||||
|
<Compile Include="Bots\Instructions\BasicInstructions.cs" />
|
||||||
|
<Compile Include="Bots\Instructions\ComplexInstructions.cs" />
|
||||||
|
<Compile Include="Bots\Instructions\Instruction.cs" />
|
||||||
<Compile Include="Bots\PlayerBot.cs" />
|
<Compile Include="Bots\PlayerBot.cs" />
|
||||||
<Compile Include="Bots\ScriptFile.cs" />
|
<Compile Include="Bots\ScriptFile.cs" />
|
||||||
<Compile Include="Chat\Chat.cs" />
|
<Compile Include="Chat\Chat.cs" />
|
||||||
@ -690,6 +693,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Blocks\Behaviour" />
|
<Folder Include="Blocks\Behaviour" />
|
||||||
|
<Folder Include="Bots\Instructions" />
|
||||||
<Folder Include="Commands" />
|
<Folder Include="Commands" />
|
||||||
<Folder Include="Commands\building" />
|
<Folder Include="Commands\building" />
|
||||||
<Folder Include="Commands\Fun" />
|
<Folder Include="Commands\Fun" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user